//父构造函数
function Animal(){
    this.name = "Animal";
}

// Animal.prototype.sayName = function(){}
Animal.prototype = {
    sayName: function(){
        console.log(this.name);
    },
}
// var a1 = new Animal();
// a1.sayName()
//子构造函数
function Dog(){
    this.color = '灰色'
}

//通过将子对象的原型对象指向父对象的一个实例来完成继承
Dog.prototype = new Animal();
Dog.prototype.constructor = Dog
//在子对象的原型上定义一个方法
Dog.prototype.sayColor = function(){
    console.log(this.color)
}
var dog = new Dog()

console.log(dog)

dog.sayColor()

dog.sayName()





